package com.workstudy.controller;

import com.workstudy.domain.Arrange;
import com.workstudy.model.ArrangeModel;
import com.workstudy.service.ArrangeService;
import com.workstudy.support.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("arrange")
public class ArrangeController extends BaseController {

    @Autowired
    private ArrangeService arrangeService;

    /**
     * 值班安排
     * @param model
     * @return
     */
    @RequestMapping("list")
    public String list(Model model){
        List<ArrangeModel> list = arrangeService.selectModel();
        model.addAttribute("list",list);
        return "arrange/list";
    }

    /**
     * 重新安排
     * @return
     */
    @RequestMapping("init")
    public String init(){
        arrangeService.init();
        return refresh();
    }

    /**
     * 我的值班安排
     * @return
     */
    @RequestMapping("myArrange")
    public String myArrange(Model model){
        List<Arrange> arrangeList = arrangeService.selectAll();
        model.addAttribute("arrangeList",arrangeList);
        return "arrange/my-arrange";
    }
}
